package com.forum.module.blog.convert.category;

import com.forum.framework.common.util.colletion.CollectionUtils;
import com.forum.framework.common.util.object.BeanUtils;
import com.forum.module.blog.controller.category.vo.CategoryRespVO;
import com.forum.module.blog.convert.article.ArticleConvert;
import com.forum.module.blog.dal.dataobject.category.CategoryDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface CategoryConvert {
    CategoryConvert INSTANCE = Mappers.getMapper(CategoryConvert.class);

    default List<CategoryRespVO> covertList(List<CategoryDO> list) {
        return CollectionUtils.convertList(list, this::covert);
    }

    default CategoryRespVO covert(CategoryDO categoryDO) {
        return BeanUtils.toBean(categoryDO, CategoryRespVO.class);
    }
}
